package com.itheima.controller;

import com.itheima.common.constant.MessageConstant;
import com.itheima.common.entity.PageResult;
import com.itheima.common.entity.QueryPageBean;
import com.itheima.common.entity.Result;
import com.itheima.pojo.Order;

import com.itheima.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequestMapping("/order")
public class OrderController {
    @Autowired
    private OrderService orderService;

    //条件分页查找
    @PostMapping("/findPage")
    public PageResult findPage(@RequestBody QueryPageBean queryPage) {
        log.info("分页查询{}", queryPage.toString());
        return orderService.findPage(queryPage);
    }

    //修改状态
    @PostMapping("/update")
    public Result update(@RequestBody Order order) {
        log.info("修改状态{}", order);
        orderService.update(order);
        return new Result(true, MessageConstant.GET_MEMBER_NUMBER_BY_MONTH_SUCCESS);
    }


}
